import java.util.ArrayList;


public class Dependency 
{
	Sign functor;
	Sign argument;
	Sign resultOfCombinator;
	int slotFilled;
	
	/*Stores information about the dependencies of the words in the sentence.
	 * Outputs information in Julia-style PARG format, or any other format you
	 * feel like.
	 */
	
	public Dependency(Sign functor, Sign argument, Sign resultOfSlash, int slotFilled)
	{
		this.functor = functor;
		this.argument = argument;
		this.resultOfCombinator = resultOfSlash;
		this.slotFilled = slotFilled;
	}
	
	public boolean isNormalForm()
	{
		if(resultOfCombinator.getCreator().equals("L Type Raising") ||
				resultOfCombinator.getCreator().equals("R Type Raising") ||
				resultOfCombinator.getCreator().equals("Forward Composition") ||
				resultOfCombinator.getCreator().equals("Backward Composition"))
			return false;
		else return true;
	}
	
	public String toPARG()
	{
		String result = "";
		result += functor.getHead().getStringIndex() + "\t" + argument.getHead().getStringIndex() + "\t" + functor.getSuperDuperTag().toString() + "\t" + slotFilled + "\t" + argument.getWords() + "\t" + functor.getWords() + "\t" + resultOfCombinator.getCreator();
		return result;
	}
	
	public Sign getFunctor()
	{
		return functor;
	}
	public Sign getArg()
	{
		return argument;
	}
	
	public int getSlotFilled()
	{
		return slotFilled;
	}
	
	public Sign getResult()
	{
		return resultOfCombinator;
	}
	
	public int hashCode()
	{
		int hash = 7;
		hash = 31 * hash + this.functor.getStringIndex();
		hash = 31 * hash + this.argument.getStringIndex();
		hash = 31 * hash + this.functor.getSuperDuperTag().toString().hashCode();
		hash = 31 * hash + this.slotFilled;
		return hash;
	}
	
	public boolean equals(Object o)
	{
		if(this == o)
			return true;
		else if (this.getClass() != o.getClass())
			return false;
		else
		{
			this.resultOfCombinator.getCreator();
			Dependency d = (Dependency) o;
			if(this.functor.getStringIndex() == d.getFunctor().getStringIndex() &&
					this.getArg().getStringIndex() == d.getArg().getStringIndex() &&
					this.functor.getSuperDuperTag().toString().equals(d.getFunctor().getSuperDuperTag().toString()) &&
					this.slotFilled == d.getSlotFilled() &&
					this.resultOfCombinator.getCreator().equals(d.getResult().getCreator()))
			{
				return true;
			}
			else return false;
		}
	}
}
